package problem125;

//验证回文串
//https://leetcode.cn/problems/valid-palindrome/description/?envType=study-plan-v2&envId=top-interview-150

class Solution {
    public boolean isPalindrome(String s) {
        StringBuffer str = new StringBuffer();
        for(char ch : s.toCharArray()) {
            if(Character.isAlphabetic(ch) || Character.isDigit(ch)) {
                str.append(Character.toLowerCase(ch));
            }
        }
        int l = 0, r = str.length()-1;
        while(l < r) {
            if(str.charAt(l) != str.charAt(r)) {
                return false;
            }
            l++;
            r--;
        }
        return true;
    }
}